/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package be.darling.scrt.statistics;

import be.darling.scrt.data.Condition;
import java.util.Iterator;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 *
 * @author jingle
 */
public abstract class SimpleStatistic extends Statistic{

    private Condition label1;
    private Condition label2;
    private boolean absolute;

    public void init()
    {
        Node node = getNodeOptions();
        Node child = node.getFirstChild();
        NodeList nodeList = child.getChildNodes();

        for(int i= 0; i<nodeList.getLength(); i++) {
            if(nodeList.item(i).getNodeName().equals("label"))  {
                if(label1==null) {
                    absolute = true;
                    label1 = new Condition( nodeList.item(i).getTextContent() );
                    addCondition(label1);
                }
                else {
                    label2 = new Condition( nodeList.item(i).getTextContent() );
                    addCondition(label2);
                }
            } else if(nodeList.item(i).getNodeName().equals("high")) {
                label1 = new Condition( nodeList.item(i).getTextContent() );
                addCondition(label1);
            } else if (nodeList.item(i).getNodeName().equals("low")) {
                 label2 = new Condition( nodeList.item(i).getTextContent() );
                 addCondition(label2);
            }
        }
        String abs = (String)getOption("absolute");
        if (abs != null){
            absolute = Boolean.parseBoolean(abs);
        }
    }

    protected Condition getLabel1()
    {
        return label1;
    }

    protected Condition getLabel2() {
        return label2;
    }

    protected boolean isAbsolute()
    {
        return absolute;
    }
    
}
